<?php

require_once 'App/Forms/LogonForm.php';
require_once 'App/Forms/SearchForm.php';
require_once 'App/Forms/MetadataForm.php';

class IndexController extends Zend_Controller_Action
{

    public function init()
    {
        $this->session = new Zend_Session_Namespace('default');
        $layout = Zend_Layout::getMvcInstance();
		$layout->message = '';
    }

    public function indexAction()
    {
    	if(isset($this->session->userID))
    	{
    		$this->_helper->viewRenderer->setNoRender(true);
    		$this->_redirect('album');
    	}
    	
        $form = new App_Forms_LogonForm();
        $form->setAction('album');
        
        $this->view->form = $form;
        
        if(isset($this->session->loginFail))
        {
        	if($this->session->loginFail)
        		echo "Login failed.";
        }
    }

	public function logoutAction()
	{
		$this->session->unsetAll();
		$this->_redirect('index');
	}
	
	public function searchAction()
	{
		$this->view->form = new App_Forms_MetadataForm();
	}
}

